package logic

import (
	"context"
	"tiktok/models/mysql"

	"tiktok/tiktokrpc/internal/svc"
	"tiktok/tiktokrpc/tiktokrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type NoteShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewNoteShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NoteShowLogic {
	return &NoteShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 笔记详情
func (l *NoteShowLogic) NoteShow(in *tiktokrpc.NoteShowRequest) (*tiktokrpc.NoteShowResponse, error) {
	// todo: add your logic here and delete this line
	var note mysql.Note
	mysql.DB.Where("id=?", in.Id).Find(&note)
	return &tiktokrpc.NoteShowResponse{
		UserId:  int64(note.UserId),
		Title:   note.Title,
		Context: note.Context,
	}, nil
}
